**************************************************************************************************
*** This do file creates the replication results for 
*** Competition for Export Markets and the Allocation of Foreign Aid: The Role of Spatial Dependence among Donor Countries	 					 	*/
*** Fabian Barthel (LSE)																		*/
*** Eric Neumayer (LSE)
*** Peter Nunnenkamp (Kiel Institute for the World Economy)										*/
*** Pablo Selaya (University of Copenhagen)														*/
*** 																							*/
*** Published in: World Development, 64 (12), 2014, pp. 350-365										*/
**************************************************************************************************
**************************************************************************************************
/* Note: 
You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 													*/
**************************************************************************************************


version 12.0
drop _all
clear matrix
clear mata


capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/

***********************************************************************************
local DIR = "D:\Research\Development finance\Nunnenkamp\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

** Create World Bank country names in export data set and save as data file

use "Article for World Development (aid_spatial).dta", clear

* xtset at donor recipient sector id - time level
xtset don_rec_sector_id year

capture dropvars laid_dummy laid_share lSL_aid_dummy_w_expshares lSL_aidshare_w_expshares lgdp_ln lpop_ln lexp_share lpol
gen laid_dummy=l.aid_dummy
gen laid_share=l.aid_share 
gen lSL_aid_dummy_w_expshares=l.SL_aid_dummy_w_expshares 
gen lSL_aidshare_w_expshares=l.SL_aidshare_w_expshares 
gen lgdp_ln=l.gdp_ln 
gen lpop_ln=l.pop_ln 
gen lexp_share=l.exp_share 
gen lpol=l.pol


*** Table 1 
*** Summary descriptive variable information
** first stage
quietly xtlogit aid_dummy l.aid_dummy l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 , fe
su aid_dummy SL_aid_dummy_w_expshares if e(sample)
quietly xtlogit aid_dummy l.aid_dummy l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & big_donors_dummy==1, fe
su aid_dummy SL_aid_dummy_w_expshares if e(sample)
quietly xtlogit aid_dummy l.aid_dummy l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & likemind_donors_dummy==1, fe
su aid_dummy SL_aid_dummy_w_expshares if e(sample)
quietly xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100  & big_donors_dummy==1, fe 
su aid_dummy SL_aid_dummy_w_expshares if e(sample)
quietly xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100  & likemind_donors_dummy==1, fe 
su aid_dummy SL_aid_dummy_w_expshares if e(sample)
quietly xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & big_donors_dummy==1, fe 
su aid_dummy SL_aid_dummy_w_expshares if e(sample)
quietly xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & likemind_donors_dummy==1, fe 
su aid_dummy SL_aid_dummy_w_expshares if e(sample)

quietly xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1, fe cluster(don_rec_sector_id)
su aid_share l.SL_aidshare_w_expshares  if e(sample)
quietly xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid_share SL_aidshare_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid_share SL_aidshare_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid_share SL_aidshare_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid_share SL_aidshare_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid_share SL_aidshare_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid_share SL_aidshare_w_expshares if e(sample)

quietly xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1, fe cluster(don_rec_sector_id)
su aid SL_aid_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid SL_aid_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid SL_aid_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid SL_aid_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid SL_aid_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid SL_aid_w_expshares if e(sample)
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
su aid SL_aid_w_expshares if e(sample)

quietly xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1, fe cluster(don_rec_sector_id)
su l.gdp_ln l.pop_ln l.exp_share l.pol unsc if e(sample)


*** Table 2 


** First-stage estimations, all donors, all sectors, FE
xtlogit aid_dummy l.aid_dummy l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 , fe
outreg2 using table2, excel 2aster  replace

** Second-stage estimations, all donors, all sectors, FE
xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table2, excel 2aster  append

** Second-stage estimations, aid level, all donors, all sectors, FE
xtreg aid l.aid l.SL_aid_w_expshares i.year year#donor_id year#recip_id if sectorncode==1000 & aid_dummy==1 , fe cluster(don_rec_sector_id)
outreg2 using table2, excel 2aster  append


** First-stage estimations, large donors, all sectors, FE
xtlogit aid_dummy l.aid_dummy l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & big_donors_dummy==1, fe
outreg2 using table2, excel 2aster  append

** Second-stage estimations, large donors, all sectors, FE
xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table2, excel 2aster  append

** Second-stage estimations, large level, all donors, all sectors, FE
xtreg aid l.aid l.SL_aid_w_expshares  i.year year#donor_id year#recip_id if e(sample), fe cluster(don_rec_sector_id)
outreg2 using table2, excel 2aster  append


** First-stage estimations, like-minded donors, all sectors, FE
xtlogit aid_dummy l.aid_dummy l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & likemind_donors_dummy==1, fe
outreg2 using table2, excel 2aster  append

** Second-stage estimations, like-minded donors, all sectors, FE
xtreg aid_share l.aid_share l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==1000 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table2, excel 2aster  append

** Second-stage estimations, aid level, like-minded donors, all sectors, FE
xtreg aid l.aid l.SL_aid_w_expshares i.year year#donor_id year#recip_id if e(sample), fe cluster(don_rec_sector_id)
outreg2 using table2, excel 2aster  append




*** Table 3, first-stage estimations, including LDV


* Large donors, social infrastructure sectors
xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100  & big_donors_dummy==1, fe 
outreg2 using table3, excel 2aster  replace

* Like-minded donors, social infrastructure sectors
xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100  & likemind_donors_dummy==1, fe 
outreg2 using table3, excel 2aster  append


* Large donors, economic infrastructure & production sectors
xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300   & big_donors_dummy==1, fe 
outreg2 using table3, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors
xtlogit aid_dummy l.aid_dummy  l.SL_aid_dummy_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300   & likemind_donors_dummy==1, fe 
outreg2 using table3, excel 2aster  append



*** Table 4, second-stage estimations, including LDV, actual exports

* Large donors, social infrastructure sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table4, excel 2aster  replace

* Large donors, social infrastructure sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares  i.year year#donor_id year#recip_id if e(sample), fe cluster(don_rec_sector_id)
outreg2 using table4, excel 2aster  append


* Like-minded donors, social infrastructure sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table4, excel 2aster  append


* Like-minded donors, social infrastructure sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares i.year year#donor_id year#recip_id if  e(sample), fe cluster(don_rec_sector_id)
outreg2 using table4, excel 2aster  append



* Large donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table4, excel 2aster  append


* estimate substantive effect
capture dropvars laid_share lSL_aidshare_w_expshares
gen laid_share=l.aid_share 
gen lSL_aidshare_w_expshares=l.SL_aidshare_w_expshares
quietly xtreg aid_share laid_share lSL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)

tempvar coeff
gen `coeff'=_b[lSL_aidshare_w_expshares]
su aid_share if e(sample)
tempvar sd_dv
gen `sd_dv'=r(sd)
su lSL_aidshare_w_expshares if e(sample)
tempvar sd_x
gen `sd_x'=r(sd)

di "One s.d increase in SL increases DV by " `sd_x'*`coeff'/`sd_dv' " s.d."


* Large donors, economic infrastructure & production sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares i.year year#donor_id year#recip_id if  e(sample), fe
outreg2 using table4, excel 2aster  append


* Like-minded donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table4, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares i.year year#donor_id year#recip_id if  e(sample), fe cluster(don_rec_sector_id)
outreg2 using table4, excel 2aster  append


*** Table 5, second-stage estimations, including LDV, predicted exports instead of actual exports
use "Article for World Development predicted exp (aid_spatial).dta", clear

* xtset at donor recipient sector id - time level
xtset don_rec_sector_id year


* Large donors, social infrastructure sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  replace

* Large donors, social infrastructure sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares  i.year year#donor_id year#recip_id if e(sample), fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  append


* Like-minded donors, social infrastructure sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  append


* Like-minded donors, social infrastructure sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares i.year year#donor_id year#recip_id if  e(sample), fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  append



* Large donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  append


* estimate substantive effect
capture dropvars laid_share lSL_aidshare_w_expshares
gen laid_share=l.aid_share 
gen lSL_aidshare_w_expshares=l.SL_aidshare_w_expshares
quietly xtreg aid_share laid_share lSL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)

tempvar coeff
gen `coeff'=_b[lSL_aidshare_w_expshares]
su aid_share if e(sample)
tempvar sd_dv
gen `sd_dv'=r(sd)
su lSL_aidshare_w_expshares if e(sample)
tempvar sd_x
gen `sd_x'=r(sd)

di "One s.d increase in SL increases DV by " `sd_x'*`coeff'/`sd_dv' " s.d."


* Large donors, economic infrastructure & production sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares i.year year#donor_id year#recip_id if  e(sample), fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  append


* Like-minded donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
xtreg aid l.aid  l.SL_aid_w_expshares i.year year#donor_id year#recip_id if  e(sample), fe cluster(don_rec_sector_id)
outreg2 using table5, excel 2aster  append



*** Table 6, like table 4, but trade-weighted
use "Article for World Development (aid_spatial).dta", clear

* xtset at donor recipient sector id - time level
xtset don_rec_sector_id year


* Large donors, social infrastructure sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_tradeshares l.gdp_ln l.pop_ln l.trade_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table6, excel 2aster  replace

* Like-minded donors, social infrastructure sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_tradeshares l.gdp_ln l.pop_ln l.trade_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table6, excel 2aster  append


* Large donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_tradeshares l.gdp_ln l.pop_ln l.trade_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table6, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  l.SL_aidshare_w_tradeshares l.gdp_ln l.pop_ln l.trade_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table6, excel 2aster  append


*** Table 7, second-stage estimations, including LDV, 3-year averaged data
use "Article for World Development three-year averages (aid_spatial).dta", replace

egen period=group(year)

* xtset at donor recipient sector id - time level
xtset don_rec_sector_id period


* Large donors, social infrastructure sectors
xtreg aid_share l.aid_share  SL_aidshare_w_expshares gdp_ln pop_ln exp_share pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table7, excel 2aster  replace

* Like-minded donors, social infrastructure sectors
xtreg aid_share l.aid_share  SL_aidshare_w_expshares gdp_ln pop_ln exp_share pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table7, excel 2aster  append


* Large donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  SL_aidshare_w_expshares gdp_ln pop_ln exp_share pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table7, excel 2aster  append


* Like-minded donors, economic infrastructure & production sectors
xtreg aid_share l.aid_share  SL_aidshare_w_expshares gdp_ln pop_ln exp_share pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1, fe cluster(don_rec_sector_id)
outreg2 using table7, excel 2aster  append



*** Table 8, second-stage estimations, including LDV, large donors jackknife
use "Article for World Development (aid_spatial).dta", clear

* xtset at donor recipient sector id - time level
xtset don_rec_sector_id year


* Large donors, social infrastructure sectors, excluding US
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1 & donor!="United States", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  replace

* Large donors, economic infrastructure & production sectors, excluding US
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1 & donor!="United States", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, social infrastructure sectors, excluding UK
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1 & donor!="United Kingdom", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, economic infrastructure & production sectors, excluding UK
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1 & donor!="United Kingdom", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, social infrastructure sectors, excluding FRA
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1 & donor!="France", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, economic infrastructure & production sectors, excluding FRA
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1 & donor!="France", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, social infrastructure sectors, excluding GER
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1 & donor!="Germany", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, economic infrastructure & production sectors, excluding GER
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1 & donor!="Germany", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, social infrastructure sectors, excluding JPN
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & big_donors_dummy==1 & donor!="Japan", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append

* Large donors, economic infrastructure & production sectors, excluding JPN
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1 & donor!="Japan", fe cluster(don_rec_sector_id)
outreg2 using table8, excel 2aster  append



*** Table 9, second-stage estimations, including LDV, like-minded donors jackknife

* Like-minded donors, social infrastructure sectors, excluding CAN
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Canada", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  replace

* Like-minded donors, economic infrastructure & production sectors, excluding CAN
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Canada", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, social infrastructure sectors, excluding DNK
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Denmark", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors, excluding DNK
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Denmark", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, social infrastructure sectors, excluding NTH
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Netherlands", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors, excluding NTH
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Netherlands", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, social infrastructure sectors, excluding NOR
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Norway", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors, excluding NOR
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Norway", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, social infrastructure sectors, excluding SWE
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100 & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Sweden", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append

* Like-minded donors, economic infrastructure & production sectors, excluding SWE
xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1 & donor!="Sweden", fe cluster(don_rec_sector_id)
outreg2 using table9, excel 2aster  append


*** Table 10, second-stage estimations, including LDV, recipient highest decile jackknife

** Large donors, social infrastructure sectors, excluding top decile of SL variable
capture drop SL_periodaverage
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100  & aid_dummy==1, fe cluster(don_rec_sector_id)
egen SL_periodaverage=mean(SL_aidshare_w_expshares) if e(sample), by(recipient)
capture drop SL_percentiles
xtile SL_percentiles=SL_periodaverage, nq(10)

* list countries
preserve

keep if SL_percentiles==10
collapse SL_percentiles, by(recipient)
list recipient

restore

xtreg aid_share l.aid_share l.SL_aidshare_w_expshares  l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100  & aid_dummy==1 & big_donors_dummy==1 & SL_percentiles!=10, fe cluster(don_rec_sector_id)
outreg2 using table10, excel 2aster  replace

** Like-minded donors, social infrastructure sectors, excluding top decile of SL variable
xtreg aid_share l.aid_share l.SL_aidshare_w_expshares  l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==100  & aid_dummy==1 & likemind_donors_dummy==1 & SL_percentiles!=10, fe cluster(don_rec_sector_id)
outreg2 using table10, excel 2aster  append


** Large donors, economic infrastructure & production sectors, excluding top decile of SL variable
capture drop SL_periodaverage
quietly xtreg aid_share l.aid_share  l.SL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1, fe cluster(don_rec_sector_id)
egen SL_periodaverage=mean(SL_aidshare_w_expshares) if e(sample), by(recipient)
capture drop SL_percentiles
xtile SL_percentiles=SL_periodaverage, nq(10)

* list countries
preserve

keep if SL_percentiles==10
collapse SL_percentiles, by(recipient)
list recipient

restore

xtreg aid_share l.aid_share l.SL_aidshare_w_expshares  l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & big_donors_dummy==1 & SL_percentiles!=10, fe cluster(don_rec_sector_id)
outreg2 using table10, excel 2aster  append

* estimate substantive effect
capture dropvars laid_share lSL_aidshare_w_expshares
gen laid_share=l.aid_share 
gen lSL_aidshare_w_expshares=l.SL_aidshare_w_expshares
quietly xtreg aid_share laid_share lSL_aidshare_w_expshares l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300 & aid_dummy==1 & big_donors_dummy==1 & SL_percentiles!=10, fe cluster(don_rec_sector_id)

tempvar coeff
gen `coeff'=_b[lSL_aidshare_w_expshares]
su aid_share if e(sample)
tempvar sd_dv
gen `sd_dv'=r(sd)
su lSL_aidshare_w_expshares if e(sample)
tempvar sd_x
gen `sd_x'=r(sd)

di "One s.d increase in SL increases DV by " `sd_x'*`coeff'/`sd_dv' " s.d."


** Like-minded donors, economic infrastructure & production sectors, excluding top decile of SL variable
xtreg aid_share l.aid_share l.SL_aidshare_w_expshares  l.gdp_ln l.pop_ln l.exp_share l.pol unsc i.year if sectorncode==200300  & aid_dummy==1 & likemind_donors_dummy==1 & SL_percentiles!=10, fe cluster(don_rec_sector_id)
outreg2 using table10, excel 2aster  append






